/**
 ******************************************************************************
 * @file    usbh_regs.h
 * @author  MCD Application Team
 * @version V1.0.0
 * @date    11/29/2010
 * @brief   USB Host mode core registers definitions
 *          Note: Device registers are defined as reserved
 ******************************************************************************
 * @copy
 *
 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
 *
 * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>
 */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USB_OTG_REGS_H__
#define __USB_OTG_REGS_H__

/* Includes ------------------------------------------------------------------*/
#include "usb_conf.h"


/** @addtogroup USB_OTG_DRIVER
 * @{
 */

/** @defgroup USB_REGS
 * @brief This file is the
 * @{
 */


/** @defgroup USB_REGS_Exported_Defines
 * @{
 */

#define USB_OTG_FS_BASE_ADDR                 0x50000000

#define USB_OTG_CORE_GLOBAL_REGS_OFFSET      0x000
#define USB_OTG_HOST_GLOBAL_REG_OFFSET       0x400
#define USB_OTG_HOST_PORT_REGS_OFFSET        0x440
#define USB_OTG_HOST_CHAN_REGS_OFFSET        0x500
#define USB_OTG_CHAN_REGS_OFFSET             0x20
#define USB_OTG_PCGCCTL_OFFSET               0xE00
#define USB_OTG_DATA_FIFO_OFFSET             0x1000
#define USB_OTG_DATA_FIFO_SIZE               0x1000

#define USB_OTG_MAX_TX_FIFOS                 15
#define USB_OTG_HOST_CHANNEL_NBR             8
#define USB_OTG_TOTAL_FIFO_SIZE              320 /* 32-Bits */
#define USB_OTG_MAX_EP0_SIZE                 64

/**
 * @}
 */

/** @defgroup USB_REGS_Exported_Types
 * @{
 */

/** @defgroup __USB_OTG_Core_register
 * @{
 */
typedef struct _USB_OTG_GREGS  //000h
{
    __IO uint32_t GOTGCTL;    /* USB_OTG Control and Status Register    000h*/
    __IO uint32_t GOTGINT;    /* USB_OTG Interrupt Register             004h*/
    __IO uint32_t GAHBCFG;    /* Core AHB Configuration Register    008h*/
    __IO uint32_t GUSBCFG;    /* Core USB Configuration Register    00Ch*/
    __IO uint32_t GRSTCTL;    /* Core Reset Register                010h*/
    __IO uint32_t GINTSTS;    /* Core Interrupt Register            014h*/
    __IO uint32_t GINTMSK;    /* Core Interrupt Mask Register       018h*/
    __IO uint32_t GRXSTSR;    /* Receive Sts Q Read Register        01Ch*/
    __IO uint32_t GRXSTSP;    /* Receive Sts Q Read & POP Register  020h*/
    __IO uint32_t GRXFSIZ;    /* Receive FIFO Size Register         024h*/
    __IO uint32_t HNPTXFSIZ; /* Non Periodic Tx FIFO Size Register 028h*/
    __IO uint32_t GNPTXSTS;   /* Non Periodic Tx FIFO/Queue Sts reg 02Ch*/
    __IO uint32_t GI2CCTL;    /* I2C Access Register                030h*/
    uint32_t Reserved34; /* PHY Vendor Control Register        034h*/
    __IO uint32_t GCCFG;      /* General Purpose IO Register        038h*/
    __IO uint32_t CID;        /* User ID Register                   03Ch*/
    uint32_t Reserved40[48];  /* Reserved                      040h-0FFh*/
    __IO uint32_t HPTXFSIZ; /* Host Periodic Tx FIFO Size Reg     100h*/
    __IO uint32_t TXnFIFOSIZ[USB_OTG_MAX_TX_FIFOS]; /* dev Periodic Transmit FIFO */
}
USB_OTG_GREGS;
/**
 * @}
 */


/** @defgroup __Host_Mode_Register_Structures
 * @{
 */
typedef struct _USB_OTG_HREGS
{
    __IO uint32_t HCFG;           /* Host Configuration Register    400h*/
    __IO uint32_t HFIR;    /* Host Frame Interval Register   404h*/
    __IO uint32_t HFNUM;       /* Host Frame Nbr/Frame Remaining 408h*/
    uint32_t Reserved40C;                 /* Reserved                       40Ch*/
    __IO uint32_t HPTXSTS; /* Host Periodic Tx FIFO/ Queue Status 410h*/
    __IO uint32_t HAINT; /* Host All Channels Interrupt Register 414h*/
    __IO uint32_t HAINTMSK; /* Host All Channels Interrupt Mask 418h*/
}
USB_OTG_HREGS;
/**
 * @}
 */


/** @defgroup __Host_Channel_Specific_Registers
 * @{
 */
typedef struct _USB_OTG_HC_REGS
{
    __IO uint32_t HCCHAR;
    __IO uint32_t Reserved_1;
    __IO uint32_t HCINT;
    __IO uint32_t HCGINTMSK;
    __IO uint32_t HCTSIZ;
    uint32_t Reserved_2[3];
}
USB_OTG_HC_REGS;
/**
 * @}
 */


/** @defgroup __otg_Core_registers
 * @{
 */
typedef struct USB_OTG_core_regs //000h
{
    USB_OTG_GREGS         *GREGS;
    USB_OTG_HREGS         *HREGS;
    USB_OTG_HC_REGS       *HC_REGS[USB_OTG_MAX_TX_FIFOS];
    __IO uint32_t         *HPRT0;
    __IO uint32_t         *DFIFO[USB_OTG_MAX_TX_FIFOS];
    __IO uint32_t         *PCGCCTL;
}
USB_OTG_CORE_REGS, *PUSB_OTG_CORE_REGS;

typedef union _USB_OTG_GAHBCFG_TypeDef
{
    uint32_t d32;
    struct
    {
        uint32_t glblintrmsk :
        1;
        uint32_t hburstlen :
        4;
        uint32_t Reserved5 :
        2;
        uint32_t nptxfemplvl_txfemplvl :
        1;
        uint32_t ptxfemplvl :
        1;
        uint32_t Reserved9_31 :
        23;
    }
    b;
} USB_OTG_GAHBCFG_TypeDef;
typedef union _USB_OTG_GUSBCFG_TypeDef
{
    uint32_t d32;
    struct
    {
        uint32_t toutcal :
        3;
        uint32_t phyif :
        1;
        uint32_t Reserved2 :
        2;
        uint32_t physel :
        1;
        uint32_t Reserved4 :
        3;
        uint32_t usbtrdtim :
        4;
        uint32_t nptxfrwnden :
        1;
        uint32_t phylpwrclksel :
        1;
        uint32_t otgutmifssel :
        1;
        uint32_t Reserved11 :
        12;
        uint32_t force_host :
        1;
        uint32_t force_dev :
        1;
        uint32_t corrupt_tx :
        1;
    }
    b;
} USB_OTG_GUSBCFG_TypeDef;
typedef union _USB_OTG_GRSTCTL_TypeDef
{
    uint32_t d32;
    struct
    {
        uint32_t csftrst :
        1;
        uint32_t hsftrst :
        1;
        uint32_t hstfrm :
        1;
        uint32_t Reserved3 :
        1;
        uint32_t rxfflsh :
        1;
        uint32_t txfflsh :
        1;
        uint32_t txfnum :
        5;
        uint32_t Reserved11_29 :
        20;
        uint32_t ahbidle :
        1;
    }
    b;
} USB_OTG_GRSTCTL_TypeDef;
typedef union _USB_OTG_GINTMSK_TypeDef
{
    uint32_t d32;
    struct
    {
        uint32_t Reserved0 :
        1;
        uint32_t modemismatch :
        1;
        uint32_t Reserved2 :
        1;
        uint32_t sofintr :
        1;
        uint32_t rxstsqlvl :
        1;
        uint32_t nptxfempty :
        1;
        uint32_t ginnakeff :
        1;
        uint32_t goutnakeff :
        1;
        uint32_t Reserved8_9 :
        2;
        uint32_t erlysuspend :
        1;
        uint32_t usbsuspend :
        1;
        uint32_t Reserved12_13 :
        2;
        uint32_t isooutdrop :
        1;
        uint32_t eopframe :
        1;
        uint32_t Reserved16_19 :
        4;
        uint32_t incomplisoin :
        1;
        uint32_t incomplisoout :
        1;
        uint32_t Reserved22_23 :
        2;
        uint32_t portintr :
        1;
        uint32_t hcintr :
        1;
        uint32_t ptxfempty :
        1;
        uint32_t Reserved27_28 :
        2;
        uint32_t disconnect :
        1;
        uint32_t reserved30 :
        1;
        uint32_t wkupintr :
        1;
    }
    b;
} USB_OTG_GINTMSK_TypeDef;
typedef union _USB_OTG_GINTSTS_TypeDef
{
    uint32_t d32;
    struct
    {
        uint32_t curmode :
        1;
        uint32_t modemismatch :
        1;
        uint32_t Reserved2 :
        1;
        uint32_t sofintr :
        1;
        uint32_t rxstsqlvl :
        1;
        uint32_t nptxfempty :
        1;
        uint32_t ginnakeff :
        1;
        uint32_t goutnakeff :
        1;
        uint32_t Reserved8 :
        2;
        uint32_t erlysuspend :
        1;
        uint32_t usbsuspend :
        1;
        uint32_t Reserved12 :
        2;
        uint32_t isooutdrop :
        1;
        uint32_t eopframe :
        1;
        uint32_t Reserved16 :
        4;
        uint32_t incomplisoin :
        1;
        uint32_t incomplisoout :
        1;
        uint32_t Reserved22_23 :
        2;
        uint32_t portintr :
        1;
        uint32_t hcintr :
        1;
        uint32_t ptxfempty :
        1;
        uint32_t Reserved27 :
        2;
        uint32_t disconnect :
        1;
        uint32_t Reserved30 :
        1;
        uint32_t wkupintr :
        1;
    }
    b;
} USB_OTG_GINTSTS_TypeDef;

typedef union _USB_OTG_HRXSTS_TypeDef
{
    uint32_t d32;
    struct
    {
        uint32_t chnum :
        4;
        uint32_t bcnt :
        11;
        uint32_t dpid :
        2;
        uint32_t pktsts :
        4;
        uint32_t Reserved :
        11;
    }
    b;
} USB_OTG_HRXFSTS_TypeDef;
typedef union _USB_OTG_FSIZ_TypeDef
{
    uint32_t d32;
    struct
    {
        uint32_t startaddr :
        16;
        uint32_t depth :
        16;
    }
    b;
} USB_OTG_FSIZ_TypeDef;
typedef union _USB_OTG_GNPTXSTS_TypeDef
{
    uint32_t d32;
    struct
    {
        uint32_t nptxfspcavail :
        16;
        uint32_t nptxqspcavail :
        8;
        uint32_t nptxqtop_terminate :
        1;
        uint32_t nptxqtop_timer :
        2;
        uint32_t nptxqtop :
        2;
        uint32_t chnum :
        2;
        uint32_t Reserved :
        1;
    }
    b;
} USB_OTG_GNPTXSTS_TypeDef;


typedef union _USB_OTG_GCCFG_TypeDef
{
    uint32_t d32;
    struct
    {
        uint32_t ovrcur :
        1;
        uint32_t otgid :
        1;
        uint32_t Reserved_in :
        14;
        uint32_t pwdn :
        1;
        uint32_t Reserved_17 :
        1;
        uint32_t vbussensingA :
        1;
        uint32_t vbussensingB :
        1;
        uint32_t SOFouten :
        1;
        uint32_t Reserved_out :
        11;
    }
    b;
} USB_OTG_GCCFG_TypeDef;

typedef union _USB_OTG_HCFG_TypeDef
{
    uint32_t d32;
    struct
    {
        uint32_t fslspclksel :
        2;
        uint32_t fslssupp :
        1;
    }
    b;
} USB_OTG_HCFG_TypeDef;
typedef union _USB_OTG_HFRMINTRVL_TypeDef
{
    uint32_t d32;
    struct
    {
        uint32_t frint :
        16;
        uint32_t Reserved :
        16;
    }
    b;
} USB_OTG_HFRMINTRVL_TypeDef;

typedef union _USB_OTG_HFNUM_TypeDef
{
    uint32_t d32;
    struct
    {
        uint32_t frnum :
        16;
        uint32_t frrem :
        16;
    }
    b;
} USB_OTG_HFNUM_TypeDef;
typedef union _USB_OTG_HPTXSTS_TypeDef
{
    uint32_t d32;
    struct
    {
        uint32_t ptxfspcavail :
        16;
        uint32_t ptxqspcavail :
        8;
        uint32_t ptxqtop_terminate :
        1;
        uint32_t ptxqtop_timer :
        2;
        uint32_t ptxqtop :
        2;
        uint32_t chnum :
        2;
        uint32_t ptxqtop_odd :
        1;
    }
    b;
} USB_OTG_HPTXSTS_TypeDef;
typedef union _USB_OTG_HPRT0_TypeDef
{
    uint32_t d32;
    struct
    {
        uint32_t prtconnsts :
        1;
        uint32_t prtconndet :
        1;
        uint32_t prtena :
        1;
        uint32_t prtenchng :
        1;
        uint32_t prtovrcurract :
        1;
        uint32_t prtovrcurrchng :
        1;
        uint32_t prtres :
        1;
        uint32_t prtsusp :
        1;
        uint32_t prtrst :
        1;
        uint32_t Reserved9 :
        1;
        uint32_t prtlnsts :
        2;
        uint32_t prtpwr :
        1;
        uint32_t prttstctl :
        4;
        uint32_t prtspd :
        2;
        uint32_t Reserved19_31 :
        13;
    }
    b;
} USB_OTG_HPRT0_TypeDef;
typedef union _USB_OTG_HAINT_TypeDef
{
    uint32_t d32;
    struct
    {
        uint32_t chint :
        16;
        uint32_t Reserved :
        16;
    }
    b;
} USB_OTG_HAINT_TypeDef;
typedef union _USB_OTG_HAINTMSK_TypeDef
{
    uint32_t d32;
    struct
    {
        uint32_t chint :
        16;
        uint32_t Reserved :
        16;
    }
    b;
} USB_OTG_HAINTMSK_TypeDef;
typedef union _USB_OTG_HCCHAR_TypeDef
{
    uint32_t d32;
    struct
    {
        uint32_t mps :
        11;
        uint32_t epnum :
        4;
        uint32_t epdir :
        1;
        uint32_t Reserved :
        1;
        uint32_t lspddev :
        1;
        uint32_t eptype :
        2;
        uint32_t multicnt :
        2;
        uint32_t devaddr :
        7;
        uint32_t oddfrm :
        1;
        uint32_t chdis :
        1;
        uint32_t chen :
        1;
    }
    b;
} USB_OTG_HCCHAR_TypeDef;
typedef union _USB_OTG_HCSPLT_TypeDef
{
    uint32_t d32;
    struct
    {
        uint32_t prtaddr :
        7;
        uint32_t Reserved7 :
        7;
        uint32_t xactpos :
        2;
        uint32_t compsplt :
        1;
        uint32_t Reserved17 :
        15;
    }
    b;
} USB_OTG_HCSPLT_TypeDef;
typedef union _USB_OTG_HCINTn_TypeDef
{
    uint32_t d32;
    struct
    {
        uint32_t xfercompl :
        1;
        uint32_t chhltd :
        1;
        uint32_t ahberr :
        1;
        uint32_t stall :
        1;
        uint32_t nak :
        1;
        uint32_t ack :
        1;
        uint32_t reserved6 :
        1;
        uint32_t xacterr :
        1;
        uint32_t bblerr :
        1;
        uint32_t frmovrun :
        1;
        uint32_t datatglerr :
        1;
        uint32_t Reserved :
        21;
    }
    b;
} USB_OTG_HCINTn_TypeDef;
typedef union _USB_OTG_HCTSIZn_TypeDef
{
    uint32_t d32;
    struct
    {
        uint32_t xfersize :
        19;
        uint32_t pktcnt :
        10;
        uint32_t pid :
        2;
        uint32_t Rerserved31 :
        1;
    }
    b;
} USB_OTG_HCTSIZn_TypeDef;
typedef union _USB_OTG_HCGINTMSK_TypeDef
{
    uint32_t d32;
    struct
    {
        uint32_t xfercompl :
        1;
        uint32_t chhltd :
        1;
        uint32_t ahberr :
        1;
        uint32_t stall :
        1;
        uint32_t nak :
        1;
        uint32_t ack :
        1;
        uint32_t Reserved6 :
        1;
        uint32_t xacterr :
        1;
        uint32_t bblerr :
        1;
        uint32_t frmovrun :
        1;
        uint32_t datatglerr :
        1;
        uint32_t Reserved :
        21;
    }
    b;
} USB_OTG_HCGINTMSK_TypeDef;
typedef union _USB_OTG_PCGCCTL_TypeDef
{
    uint32_t d32;
    struct
    {
        uint32_t stoppclk :
        1;
        uint32_t gatehclk :
        1;
        uint32_t Reserved :
        30;
    }
    b;
} USB_OTG_PCGCCTL_TypeDef;

/**
 * @}
 */


/** @defgroup USB_REGS_Exported_Macros
 * @{
 */
/**
 * @}
 */

/** @defgroup USB_REGS_Exported_Variables
 * @{
 */
/**
 * @}
 */

/** @defgroup USB_REGS_Exported_FunctionsPrototype
 * @{
 */
/**
 * @}
 */


#endif //__USB_OTG_REGS_H__


/**
 * @}
 */

/**
 * @}
 */
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/

